<template>
	<view class="con">
		<view v-if="type==2||type==1||type==4" class="flex-ju-b flex-wrap pb30">
			
			<view @click="jumpPage(item)" v-for="(item,h) in hotList" :key="h" class="mb15">
				<image class="himgwid" :src="item.cover_image"></image>
				<view class=" texhom">
					{{item.title}}
				</view>
				<view class="">
					￥{{item.original_price}}
				</view>
			</view>
			 
		</view>
		
		<view v-if="type==3" class="flex-ju-b mt15 center flex-wrap pb30">
			<view class="mb20" @click="cetwlist(item.id)" v-for="(item,p) in categorylist" :key="p">
				<template v-if="item.status==1">
					<image  style="width:100rpx;height:100rpx;" :src="item.image"></image>
					<view class="color4dd size12">{{item.name}}</view>
				</template>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				categorylist:[],
				hotList:[],
				page: 1,
				type:"",
				id:""
			}
		},
		onLoad(option) {
			this.type=option.type
			this.id=option.id
			if (option.type == 1) {
				uni.setNavigationBarTitle({
					title: '热门推荐'
				})
				this.getre()
			} else if (option.type == 2) {
				uni.setNavigationBarTitle({
					title: '镇店精选'
				})
				this.getre()
			}else if(option.type == 3){
				uni.setNavigationBarTitle({
					title: '爆款IP导航'
				})
				this.getip()
			}else if(option.type == 4){
				uni.setNavigationBarTitle({
					title: '爆款IP导航'
				})
				this.getips()
			}
		},
		onReachBottom() {
			this.page++
			if(this.type == 3){
				this.getip()
				return
			}
			if(this.type == 4){
				this.getips()
				return
			}
			this.getre()
		},
		methods: {
			cetwlist(id){
				this.type=4
				this.id=id
				this.getips()
			},
			getips(){
				this.$http('v1.activitysList', {
					page:this.page,
					rows:90,
					ip:this.id
				}).then((res) => {
					if (res.code === 1) {
						let {
							data
						} = res;
						
						if(data.list.length){
							this.hotList = [...this.hotList, ...data.list];
						}
						
					}
				})
			},
			getip(){
				this.$http('v1.categorylist', {
					page: this.page,
					rows: 90,
				}).then((res) => {
					if (res.code == 1) {
						if(res.data.list.length){
							this.categorylist = [...this.categorylist, ...res.data.list];
						}
					}
				})
			},
			jumpPage(e) {
			  switch (e.activity_type) {
			    case '1':
			      uni.navigateTo({
			        url: `/pages/rewardGoods/portrait/index?id=${e.id}`,
			      });
			
			      break;
			    case '2':
			      uni.navigateTo({
			        url: `/pages/fukubukuro/extract/extract?id=${e.id}`,
			      });
			      break;
			  }
			},
			getre() {
				this.$http('v1.activitysList', {
					tag:this.type,
					page: this.page,
					rows: 90,
				}).then((res) => {
					if (res.code === 1) {
						let {
							data
						} = res;
						
						if(data.list.length){
							this.hotList = [...this.hotList, ...data.list];
						}
						
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background: #fff;
	}
	.texhom {
		width: 335rpx;
		/* height: 50px; */
	}
	.himgwid {
		width: 335rpx;
		height: 335rpx;
		border-radius: 20rpx;
	}
</style>